Imports MIMS.WRS.Business
Imports MIMS.WRS.Entities
Imports System.Data
Imports System.Data.Common

Public Class SupplierIncompleteReport
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents rptList As System.Web.UI.WebControls.Repeater
    Protected WithEvents lbSupplier As System.Web.UI.WebControls.ListBox
    Protected WithEvents btnSelect As System.Web.UI.WebControls.Button
    Protected WithEvents divSupplierSelect As System.Web.UI.HtmlControls.HtmlGenericControl
    Protected WithEvents divContent As System.Web.UI.HtmlControls.HtmlGenericControl

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub ShowResult()
        Me.divContent.Visible = True
        Me.divSupplierSelect.Visible = False

        rptList.DataSource = ShippingStatusReportService.GetSupplierIncompleteReport(RequestContext.CurrentUser.ActiveOfficeID, Integer.Parse(lbSupplier.SelectedItem.Value))
        rptList.DataBind()
    End Sub

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Security.DenyIDSUser()

        If (Not IsPostBack) Then
            Me.divContent.Visible = False
            Me.divSupplierSelect.Visible = True

            lbSupplier.DataSource = ShippingStatusReportService.GetSupplierList(RequestContext.CurrentUser.ActiveOfficeID)
            lbSupplier.DataTextField = ShippingStatusReportColumns.PONo_Supplier.ToString()
            lbSupplier.DataTextFormatString = "{0:D3}"
            lbSupplier.DataValueField = ShippingStatusReportColumns.PONo_Supplier.ToString()
            lbSupplier.DataBind()

        End If
    End Sub

    Protected Function GetBulkText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToString(data).Length = 0 Then
            Return Utilities.NAText
        Else
            Return Utilities.GetBulkMeaning(Convert.ToString(data))
        End If
    End Function

    Protected Function GetBulkOrderNoText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToInt32(data) = 0 Then
            Return Utilities.NAText
        Else
            Return Convert.ToInt32(data).ToString().PadLeft(6, "0"c)
        End If
    End Function

    'Protected Function GetSizeText(ByVal data As Object) As String
    '    If data Is DBNull.Value OrElse Convert.ToString(data).Length = 0 Then
    '        Return "<span class=""highlight"">N/A</span>"
    '    Else
    '        Return Convert.ToString(data)
    '    End If
    'End Function

    Protected Function GetPackText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToString(data).Length = 0 Then
            Return Utilities.NAText
        Else
            Return Utilities.GetPackMeaning(Convert.ToString(data))
        End If
    End Function

    Protected Function GetTypeText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToString(data).Length = 0 Then
            Return Utilities.NAText
        Else
            Return Utilities.GetTypeMeaning(Convert.ToString(data))
        End If
    End Function

    Protected Function GetPrimaryText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToString(data).Trim().Length = 0 Then
            Return Utilities.NAText
        Else
            Return Utilities.GetPrimaryMeaning(Convert.ToString(data))
        End If
    End Function

    Protected Function GetConText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToInt32(data) = 0 Then
            Return Utilities.NAText
        Else
            Return Convert.ToInt32(data).ToString()
        End If
    End Function

    Protected Function GetNullText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToString(data).Length = 0 Then
            Return Utilities.NAText
        Else
            Return Convert.ToString(data)
        End If
    End Function

    Protected Function GetOrderDateText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToDateTime(data).Equals(Nulls.NullDate) Then
            Return Utilities.NAText
        Else
            Return Convert.ToDateTime(data).ToShortDateString()
        End If
    End Function

    Protected Function GetSupplierText(ByVal data As Object) As String
        If data Is DBNull.Value OrElse Convert.ToInt32(data).Equals(Nulls.NullInteger) Then
            Return Utilities.NAText
        Else
            Return String.Format("<span class=""highlight2"">{0}</span>", Convert.ToInt32(data).ToString().PadLeft(3, "0"c))
        End If
    End Function

    Private Sub btnSelect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelect.Click
        ShowResult()
    End Sub
End Class
